package com.neu.elm.mapper;

import com.neu.elm.po.DeliveryAddress;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author:csw
 * @Date: 14:12 2020/9/15
 */
@Mapper
public interface DeliveryAddressMapper {

    //用户id查询所有地址
    @Select("select * from deliveryAddress where userId=#{userId} order by daId")
    public List<DeliveryAddress> listDeliveryAddressByUserId(String userId);

    //按配送地址的id查询
    @Select("select * from deliveryAddress where daId=#{daId}")
    public DeliveryAddress getDeliveryAddressById(Integer daId);

    //保存地址
    @Insert("insert into deliveryAddress values(null,#{contactName},#{contactSex},#{contactTel},#{address},#{userId})")
    public int saveDeliveryAddress(DeliveryAddress deliveryAddress);

    //修改地址
    @Update("update deliveryAddress set contactName=#{contactName},contactSex=#{contactSex},contactTel=#{contactTel},address=#{address} where daId=#{daId}")
    public int updateDeliverAddress(DeliveryAddress deliveryAddress);


    //删除
    @Delete("delete from deliveryAddress where daId=#{daId}")
    public int removeDeliveryAddress(Integer daId);







}
